package com.tengol.demo.design.pattern.structural.flyweight.demo2;

/**
 * 单元测试：享元模式（实例二）
 * 业务场景：假如某科技公司提供网站制作服务，由于技术实力雄厚，该公司将网站模型化，
 * 将公共相同的网站定制成模板，有相似需求时直接修改部分内容即可快速生产网站，同时也降低网站制作成本。
 *
 * @author dongrui
 * @date 2019/03/07
 */
public class WebSiteFlyweightTest {
    public static void main(String[] args) {
        WebSite w1 = WebSiteFactory.getWebSite("产品展示");
        w1.use(new User("admin"));
        WebSite w2 = WebSiteFactory.getWebSite("产品展示");
        w2.use(new User("zhangsan"));
        WebSite w3 = WebSiteFactory.getWebSite("产品展示");
        w3.use(new User("lisi"));
        WebSite w4 = WebSiteFactory.getWebSite("电子商务");
        w4.use(new User("admin"));
        WebSite w5 = WebSiteFactory.getWebSite("电子商务");
        w5.use(new User("wangwu"));
        WebSite w6 = WebSiteFactory.getWebSite("电子商务");
        w6.use(new User("xiaobeijing"));
        System.out.println("网站总数：" + WebSiteFactory.getSize());

    }
}
